﻿using AutoMapper;
using Common.Library;

namespace Authority.Model
{
    /// <summary>
    /// 权限相关映射
    /// </summary>
    public class AuthorityProfile : Profile
    {
        public AuthorityProfile()
        {
            #region Button-按钮相关映射

            CreateMap<ButtonsOperateRequest, SysButtonEntity>();

            #endregion

            #region Menus-菜单相关映射

            CreateMap<MenusRootRequest, SysMenuEntity>();

            CreateMap<MenusChildRequest, SysMenuEntity>();

            CreateMap<MenusModifyRequest, SysMenuEntity>();

            CreateMap<SysMenuEntity, MenusListResponse>();

            #endregion

            #region Role-角色相关映射

            CreateMap<RoleRootRequest, SysRoleEntity>();

            CreateMap<RoleChildRequest, SysRoleEntity>();

            CreateMap<RoleModifyRequest, SysRoleEntity>();

            CreateMap<SysMenuEntity, RoleMenusListResponse>();

            CreateMap<RoleMenuButtonModifyInfo, SysRoleButtonEntity>();

            CreateMap<SysRoleEntity, SelectListInfo>()
                .ForMember(p => p.value, opt => { opt.MapFrom(t => t.gCode); })
                .ForMember(p => p.name, opt => { opt.MapFrom(t => t.sName); });

            CreateMap<View_RoleMenuButtonEntity, RoleMenuButtonsListResponse>();

            #endregion

            #region Department-部门相关映射

            CreateMap<SysDepartmentEntity, DepartmentsListResponse>();

            CreateMap<DepartmentRootRequest, SysDepartmentEntity>();

            CreateMap<DepartmentChildRequest, SysDepartmentEntity>();

            CreateMap<DepartmentModifyRequest, SysDepartmentEntity>();

            #endregion

            #region Post-岗位相关映射

            CreateMap<PostOperateRequest, SysPostEntity>();

            #endregion

            #region User-管理员相关映射

            CreateMap<SysPostEntity, SelectListInfo>()
                .ForMember(p => p.value, opt => { opt.MapFrom(t => t.gCode); })
                .ForMember(p => p.name, opt => { opt.MapFrom(t => t.sName); });

            CreateMap<UserAddRequest, SysUserEntity>();

            CreateMap<UserModifyRequest, SysUserEntity>();

            #endregion

            #region Organization-公司相关映射

            CreateMap<OrganizationOperateRequest, SysOrganizationEntity>();

            ///组织机构入驻请求
            CreateMap<OrganizationSettledRequest, SysOrganizationEntity>();
            
            #endregion

        }
    }
}
